//Accepted
#include <cstdio>
#include <cstring>

int n, m, i, j, k, x, y, t=1;
int d[8][2]={{1,0},{-1,0},{0,1},{0,-1}, {1,1}, {-1,1}, {1,-1},{-1,-1}};
int b[100][100];
char a[100][101];


bool ok(int l, int c){
	return (0<=l&&l<n)&&(0<=c&&c<m);
}
int main(){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	
	scanf("%d%d", &n, &m);
	
	while(n+m){
		for(i=0;i<n;++i)
			scanf("%s", a[i]);
		
		memset(b, 0, sizeof(b));
		
		for(i=0;i<n;++i)
		for(j=0;j<m;++j)
		if(a[i][j]=='*')
		for(k=0;k<8;++k)
		{
			y=i+d[k][0];
			x=j+d[k][1];
			
			if(ok(y,x)){
				b[y][x]++;
			}
		}
		
		
		printf("Field #%d:\n", t++);
		for(i=0;i<n;++i){
			for(j=0;j<m;++j){
				if(a[i][j]=='*')printf("*");
				else printf("%d",b[i][j]);
			}
			printf("\n");
		}
		
		scanf("%d%d", &n, &m);
		if(n+m)
		printf("\n");
		
	}
	
	return 0;
}
